(function(angular) {
	'use strict';
	angular.module('fs.waf').factory('sampleCompanyService', sampleCompanyService);
	sampleCompanyService.$inject = [ '$q', 'loggerFactory', 'commonService'];
	function sampleCompanyService($q, loggerFactory, commonService) {
		var log = loggerFactory.getLogger("sampleCompanyService");
		var sampleCompanyServiceObj = this;
		function dateDisabled(dateModel) {
			var date = dateModel.date, mode = dateModel.mode;
			if(mode === 'day') {
				return commonService.isHoliday(date, sampleCompanyServiceObj.holidays);
			} else {
				return false;
			}
		}
		function getSiteCodeOptions() {
			var options = {
				"callback" : {
					"changed" : "vm.siteCodeChanged"
				},
				"data" : [ {
					"label" : "MD BANK",
					"value" : "MDBANK"
				}, {
					"label" : "BANK 01",
					"value" : "BANK01"
				}, {
					"label" : "BANK 02",
					"value" : "BANK02"
				}, {
					"label" : "BANK 03",
					"value" : "BANK03"
				}, {
					"label" : "BANK 04",
					"value" : "BANK04"
				} ]
			};
			return options;
		}
		function getCompanyTypeOptions() {
			var options = {
				"callback" : {
					"changed" : "vm.siteCodeChanged"
				},
				"data" : [ {
					"value" : "EXPORTER",
					"label" : "label.company.seller"
				}, {
					"value" : "IMPORTER",
					"label" : "label.company.buyer"
				}, {
					"value" : "GUARANTEE",
					"label" : "label.company.guarantee"
				} ]
			};
			return options;
		}
		function getCompanyTypeOptions2() {
			var options = {
				"callback" : {
					"changed" : "vm.siteCodeChanged"
				},
				"groups" : [ {
					"title" : "Group 1",
					"showHeadCheckbox" : true,
					"data" : [ {
						"value" : "EXPORTER1",
						"label" : "label.company.seller"
					}, {
						"value" : "IMPORTER1",
						"label" : "label.company.buyer"
					}, {
						"value" : "GUARANTEE1",
						"label" : "label.company.guarantee"
					} ]
				}, {
					"title" : "Group 2",
					"showHeadCheckbox" : true,
					"data" : [ {
						"value" : "EXPORTER2",
						"label" : "label.company.seller"
					}, {
						"value" : "IMPORTER2",
						"label" : "label.company.buyer"
					}, {
						"value" : "GUARANTEE2",
						"label" : "label.company.guarantee"
					} ]
				}, {
					"title" : "Group 3",
					"showHeadCheckbox" : true,
					"data" : [ {
						"value" : "EXPORTER3",
						"label" : "label.company.seller"
					}, {
						"value" : "IMPORTER3",
						"label" : "label.company.buyer"
					}, {
						"value" : "GUARANTEE3",
						"label" : "label.company.guarantee"
					} ]
				} ]
			};
			return options;
		}
		function getCompanyTypeLookupOptions() {
			var options = {
				"callback" : {
					"changed" : "vm.siteCodeChanged"
				},
				"id" : "cda.companyType",
				"params" : {
					"paramName1" : "<siteCode",
					"paramName2" : "fixedValue",
				},
				"boundTo" : {
					"companyType" : "companyType2"
				},
				"okEvent" : true,
				"cancelEvent" : false
			};
			return options;
		}
		function getSensitiveOptions() {
			var options = {
				"callback" : {
					"changed" : "vm.siteCodeChanged"
				},
				"mask" : true,
				"positiveOffset" : 2,
				"negativeOffset" : 3
			};
			return options;
		}
		function getCcyOptions() {
			var options = {
				"callback" : {
					"changed" : "vm.siteCodeChanged"
				},
				"data" : [ {
					"label" : "CNY",
					"value" : "CNY"
				}, {
					"label" : "USD",
					"value" : "USD"
				} ]
			};
			return options;
		}
		function getHolidays(params) {
			var defer = $q.defer();
			commonService.getHolidays(params).then(function(response) {
				sampleCompanyServiceObj.holidays = response;
				defer.resolve(response);
			});
			return defer.promise;
		}
		return {
			dateDisabled : dateDisabled,
			getSiteCodeOptions : getSiteCodeOptions,
			getCompanyTypeOptions : getCompanyTypeOptions,
			getCompanyTypeOptions2 : getCompanyTypeOptions2,
			getCompanyTypeLookupOptions : getCompanyTypeLookupOptions,
			getSensitiveOptions : getSensitiveOptions,
			getCcyOptions : getCcyOptions,
			getHolidays : getHolidays
		};
	}
})(angular);